package com.data.data_observer_api.Controller;

import com.data.data_observer_api.dao.FollowerDAO;
import com.data.data_observer_api.vo.FollowerVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
public class FollowerController {
    private final FollowerDAO followerDAO;

    @GetMapping("/getRankTop")
    public List<Map<String, Object>> getRankTop() {

        return followerDAO.getRankTop();
    }

    @GetMapping("/getRankDesc/{day}")
    public List<Map<String, Object>> getRankDesc(@PathVariable Integer day) {
        if (day == 1) {
            day = 1;
        } else if (day == 7) {
            day = 7;
        } else if (day == 30) {
            day = 30;
        } else {
            day = 1;
        }

        return followerDAO.getRankDesc(day);
    }

    @GetMapping("/getFollower/{id}")
    public FollowerVO getFollower(@PathVariable Long id) {
        FollowerVO followerVO = new FollowerVO();
        followerVO.setFollower(91257);
        followerVO.setUid(12);
        followerVO.setDataTime(new Timestamp(System.currentTimeMillis()));

        return followerVO;
    }

    @GetMapping("/getRankAsc/{day}")
    public List<Map<String, Object>> getRankAsc(@PathVariable Integer day) {
        if (day == 1) {
            day = 1;
        } else if (day == 7) {
            day = 7;
        } else if (day == 30) {
            day = 30;
        } else {
            day = 1;
        }
        return followerDAO.getRankAsc(day);
    }

    @GetMapping("/getWeekFollower/{id}")
    public List<Map<String, Object>> getWeekFollower(@PathVariable Long id) {

        return followerDAO.getFollower(id);
    }
}